// hyb_yl/mysubpages/pages/physicalOrder/physicalOrder.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tab: [{
      name: "待支付"
    },
    {
      name: "待接诊"
    },
    {
      name: "已到诊"
    },
    {
      name: "已结束"
    },
    {
      name: "已取消"
    },
    ], //选项卡
    current: 0,
    index: 0,
    unscramble: [
      { "ordernums": '1151454545', "code": '待支付', "t_thumb": '../../images/tjbj.png', 't_name': '名字', 'money': 12, "time": '2020-10-25 15:56',"ifpay":"0"},
      { "ordernums": '1151454545', "code": '待支付', "t_thumb": '../../images/tjbj.png', 't_name': '名字', 'money': 12, "time": '2020-10-25 15:56', "ifpay": "1" },
      { "ordernums": '1151454545', "code": '待支付', "t_thumb": '../../images/tjbj.png', 't_name': '名字', 'money': 12, "time": '2020-10-25 15:56', "ifpay": "2" },
      { "ordernums": '1151454545', "code": '待支付', "t_thumb": '../../images/tjbj.png', 't_name': '名字', 'money': 12, "time": '2020-10-25 15:56', "ifpay": "1" },
    ],
    wzf: [],
    ySuccess: [],
    tijians: [],
    concals: [],
  },
  // 切换
  chooseTab: function (e) {
    var index = e.currentTarget.dataset.i
    this.setData({
      current: index,
    })
    var unscramble = this.data.unscramble
    var wzf = []
    var ySuccess = []
    let tijians = []
    let concals = []
    if (index == 1) {
      for (let i = 0; i < unscramble.length; i++) {
        if (unscramble[i].ifpay == 0) {
          wzf.push(unscramble[i])
        }
      }
      this.setData({
        wzf: wzf
      })
    } else if (index == 2) {
      for (let i = 0; i < unscramble.length; i++) {
        if (unscramble[i].ifpay == 1) {
          ySuccess.push(unscramble[i])
        }
      }
      this.setData({
        ySuccess: ySuccess
      })
    } else if (index == 3) {
      for (let i = 0; i < unscramble.length; i++) {
        if (unscramble[i].ifpay == 2) {
          tijians.push(unscramble[i])
        }
      }
      this.setData({
        tijians
      })
    } else if (index == 4) {
      for (let i = 0; i < unscramble.length; i++) {
        if (unscramble[i].ifpay == 2) {
          concals.push(unscramble[i])
        }
      }
      this.setData({
        concals
      })
    }
    // this.ge tAllshoporder(index)
  },
  // orderinfo:function(e){
  //   // var unscramble = this.data.unscramble
  //   // console.log(unscramble)
  //   console.log(e)
  //   var id= e.currentTarget.dataset.id
  //   wx.navigateTo({
  //     url: '/hyb_yl/userLife/pages/tijian/detail/detail?tid=' +id,
  //   })
  // },
  lookdetail: function (e) {
    console.log(e)
    wx.navigateTo({
      url: '/hyb_yl/mycenter/pages/regiOrderinfor/regiOrderinfor',
    })
  },
  tixing: function () {
    wx.navigateTo({
      url: '/hyb_yl/mysubpages/pages/diagReport/diagReport',
    })
  },
  zhifu() {
    wx.requestPayment({
      timeStamp: '',
      nonceStr: '',
      package: '',
      signType: '',
      paySign: '',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    // this.getMytjianorder()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  getMytjianorder() {
    var that = this
    app.util.request({
      'url': 'entry/wxapp/tijian.orderlist',
      data: {
        openid: wx.getStorageSync('openid')
      },
      success: function (res) {
        console.log(res)
        that.setData({
          unscramble: res.data
        })
      }
    })
  }
})